﻿using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class Data_OrderDetail : Data
    {
        #region [OrderDetail_Insert]
        public void OrderDetail_Insert(OrderDetail data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_OrderDetail_Insert", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Ord_ID", data.Ord_ID);
                cmd.Parameters.Add("@Train_Schedule_ID", data.Train_Schedule_ID);
                cmd.Parameters.Add("@Type_Ticket", data.Type_Ticket);
                cmd.Parameters.Add("@Quantity", data.Quantity);

                cmd.ExecuteNonQuery();
            }
        }
        #endregion


        #region [OrderDetail_GetByAll]
        public DataTable OrderDetail_GetByAll()
        {
            using (SqlCommand cmd = new SqlCommand("sp_OrderDetail_GetByAll", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                return dt;
            }
        }
        #endregion
    }
}
